//
//  ERLangureChoiceViewController.m
//  ExchangeRate
//
//  Created by lanou on 15/11/14.
//  Copyright © 2015年 方义强. All rights reserved.
//

#import "ERLangureChoiceViewController.h"
#define kCELL @"Langure"
@interface ERLangureChoiceViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *mainTV;
@property (nonatomic, strong) NSArray *langureArr;
@property (nonatomic, strong) NSArray *simLanArr;
@end

@implementation ERLangureChoiceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self rewriteTopView];
    _langureArr = @[@"简体中文", @"日本語", @"한국의", @"Engilsh", @"русский", @"Deutsch", @"français", @"Italiano"];
    _simLanArr = @[@"zh-Hans",@"ja",@"ko",@"en",@"uk",@"de",@"fr",@"it"];
    [self createTableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark 重写topView
- (void) rewriteTopView
{
    _leftButton.imageEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 30);
    [_leftButton setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:(UIControlStateNormal)];
    [self.leftButton addTarget:self action:@selector(clickBackButton:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.titleLabel.text = NSLocalizedString(@"语言", nil);
}

#pragma mark 点击返回按钮实现事件
- (void) clickBackButton:(UIButton *)btn
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark tableview 创建
- (void) createTableView
{
    _mainTV = [[UITableView alloc] initWithFrame:CGRectMake(0, 70, kSCREENWIDTH, kSCREENHEIGHT - 70) style:(UITableViewStylePlain)];
    _mainTV.backgroundColor = [UIColor colorWithWhite:0.213 alpha:1.000];
    [_mainTV registerClass:[UITableViewCell class] forCellReuseIdentifier:kCELL];
    _mainTV.delegate = self;
    _mainTV.dataSource = self;
    _mainTV.scrollEnabled = NO;
    _mainTV.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_mainTV];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _langureArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCELL forIndexPath:indexPath];
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.text = _langureArr[indexPath.row];
    cell.backgroundColor = [UIColor colorWithWhite:0.278 alpha:1.000];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//   // [[NSNotificationCenter defaultCenter] postNotificationName:@"chang" object:@"change" userInfo:[NSDictionary dictionaryWithObject:_simLanArr[indexPath.row] forKey:@"lan"]];
//}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
